import React, { Component } from 'react';

class App extends Component {
  clickHandler1 = (event) => { // 类中定义箭头函数
    console.log(this)
    console.log(event)
  }

  clickHandler3 = (params, event) => {
    console.log(params)
    console.log(this)
    console.log(event)
  }

  clickHandler4 = (params1, params2, event) => {
    console.log(params1)
    console.log(params2)
    console.log(this)
    console.log(event)
  }
  render() {
    return (
      <div>
        <h1>es6绑定事件以及传递参数</h1>
        <button onClick={ this.clickHandler1 }>点击-绑定事件方法1</button>
        <button onClick={ (event) => { // jsx中写箭头函数
          console.log(this)
          console.log(event)
        } }>点击-绑定事件方法2</button>
        <button onClick={ this.clickHandler3.bind(this, '参数') }>传递参数1</button>
        <button onClick={ (event) => this.clickHandler4('aaa', 'bbb', event) }>传递参数2</button>
      </div>
    );
  }
}

export default App;